<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Login</title>
</head>
<body>
    <div>
        <form action="#" method="POST">
            <input id="username" type="text" name="username" placeholder="username" />
            <input id="pwd" type="password" name="pwd" placeholder="请输入密码" />
            <button type="button" id="sBtn">提交</button>
        </form>
    </div>


    <script src="../static/js/jquery-2.0.3.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#sBtn').click(function (e) {
                $.ajax({
                    type:"POST",
                    url:"/login",
                    data:{
                        "userName":$('#username').val(),
                        "password":$('#pwd').val()
                    },
                    dataType:"json",
                    success:function (data) {
                        if (data.result == "1") {
                            window.location.href ="/learn";
                        } else {
                            alert("账号密码不能为空！");
                        }
                    }
                });
            });
        });
    </script>
</body>
</html>